package com.un.ebs.businessObject.controller;

import com.un.ebs.core.metadata.FunctionInfo;
import com.un.ebs.core.metadata.ServiceInfo;
import com.un.ebs.core.util.WebResult;
import com.un.ebs.core.util.WebUtils;
import com.un.ebs.businessObject.service.RelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author zc
 * @ClassName RelController
 * @Description context
 * @Date 2021/1/8
 */
@RestController
@RequestMapping("rel")
@Api(value = "rel-table-column", description = "表关系字段")
public class RelController {
    @Autowired
    private RelService relService;

    /**
     * 获取所有serviceInfo
     *
     * @return
     */
    @GetMapping("services")
    @ApiOperation("服务定义 : @RestController")
    public WebResult<List<ServiceInfo>> queryServices() {
        return WebUtils.success(relService.queryServices());
    }

    /**
     * 根据serviceName 获取function
     *
     * @param serviceName ServiceInfo
     * @return
     */
    @GetMapping(value = "function")
    @ApiOperation("接口定义 : @RequestMapping,@GetMapping,@PostMapping...")
    public WebResult<FunctionInfo> queryFunctions(@RequestParam String serviceName) {
        return WebUtils.success(relService.queryFunctions(serviceName));
    }
}
